/*
 * @lc app=leetcode.cn id=11 lang=cpp
 *
 * [11] 盛最多水的容器
 */

// @lc code=start
class Solution
{
public:
    int maxArea(vector<int> &height)
    {
        int res = 0; //保存结果
        int left = 0;
        int right = height.size() - 1;
        while (left < right)
        {
            //首先记录当前的值
            res = max(res, min(height[left], height[right]) * (right - left));
            //移动较小的位置
            if (height[left] > height[right])
            {
                right--;
            }
            else
            {
                left++;
            }
        }
        return res;
    }
};
// @lc code=end
